package com.zaofan.constant;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public enum PowerIndex {
    USER(1, "会员中心"),
    ORDER(2, "订单管理"),
    CONTENT(3, "内容管理"),
    COMMENT(4, "评论管理"),
    ACTIVITY(5, "活动管理"),
    RECHARGE(6, "在线充值"),
    PREPAID(7, "充值卡"),
    AREA(8, "区域管理"),
    SHOP(9, "商家管理"),
    CARRIER(10, "承运商管理"),
    GOODS(11, "商城管理"),
    FANS(12, "范粉管理"),
    SITE(13, "网站信息管理"),
    OPEN(14, "申请开通"),
    REFRESH(15, "网站数据更新"),
    QrCode(16,"二维码管理"),
    Coupon(17,"优惠券管理"),
    Hotel(18,"酒店管理")
    ;

    private static Map<Integer, PowerIndex> CODE_MAP;

    static {
        Map<Integer, PowerIndex> map = new HashMap<Integer, PowerIndex>();
        for (PowerIndex powerIndex : PowerIndex.values()) {
            map.put(powerIndex.code, powerIndex);
        }

        CODE_MAP = Collections.unmodifiableMap(map);
    }

    private Integer code;
    private String name;

    PowerIndex(Integer code, String name) {
        this.code = code;
        this.name = name;
    }


    public String getName() {
        return name;
    }

    public int getCode() {
        return code;
    }

    public static String getNameByCode(Integer code) {
        return CODE_MAP.containsKey(code) ? CODE_MAP.get(code).name : null;

    }

    public static PowerIndex fromCode(Integer code) {
        return CODE_MAP.get(code);
    }
}
